// pages/home/home.js
import config from "../../utils/config.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banner:[],
    imgUrl: [
      "https://kiefaluo.gitee.io/beautifulgirl/images/nav1.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/nav2.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/nav3.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/pic1.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/pic2.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/pic3.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/pic4.png",
      "https://kiefaluo.gitee.io/beautifulgirl/images/pic5.png",
    ],
    category:[],
    yph: "https://kiefaluo.gitee.io/beautifulgirl/images/youpinghuizhuanqu.png",
    vip1:"https://kiefaluo.gitee.io/beautifulgirl/images/viphuiyuan.png",
    vip2:"https://kiefaluo.gitee.io/beautifulgirl/images/shengji.png"
  },
  vipAdd:function(){
    wx.navigateTo({
      url: '../agentml/agentml'
    })
  },
  
  //分类锚点跳转
  contBox:function(){
    wx.createSelectorQuery().select('.cate').boundingClientRect(function(re){
      wx.createSelectorQuery().select('.web').boundingClientRect(function(rect){
        wx.pageScrollTo({
          scrollTop: rect.height-re.height,
          duration:1000
        })
      }).exec()
    }).exec()
  },
    toProDedtail:function(){
        wx.navigateTo({
            url: '../proDetail/proDetail',
        })
    },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.request({
      url: config.index,
      success:function(res){
        console.log(res);
        that.setData({
          banner:res.data.data.banner,
          category:res.data.data.categoryList
        })
      }
    })
  },
  yph:function(e){
    var id = e.currentTarget.dataset.name;
    var caID = e.currentTarget.dataset.id;
    wx.setStorageSync("id", id)
    wx.setStorageSync("caID", caID)
    wx.navigateTo({
      url: '../categorylist/categorylist',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})